/*
 * Copyright 2000-2020 YGSoft.Inc All Rights Reserved.
 */
package com.shuaqiu.simback.dao;

import java.util.List;
import java.util.Map;

import com.shuaqiu.simback.model.Model;

/**
 * .<br>
 *
 * @author liulongzhenhai <br>
 * @version 1.0.0 2013-9-9<br>
 */
public interface DBOperate {

    /**
     * 获取clazz 对应的表的 Bo,通过主键查询. <br>
     *
     * @param id id
     * @return 返回c
     * @author liulongzhenhai 2013-9-9 下午5:12:30 <br>
     */
    <T extends Model> T getBo(Class<T> clazz, Integer id);

    /**
     * 获取clazz 对应的表的 Bo,通过主键查询. <br>
     *
     * @param id id
     * @return 返回c
     * @author liulongzhenhai 2013-9-9 下午5:12:30 <br>
     */
    <T extends Model> Map<String, Object> getMap(Class<T> clazz, Integer id);

    /**
     * 通过sql获取类的结果集. <br>
     *
     * @param clazz        model
     * @param sqlCondition sql condition, the clause after "where" key, i.e. username = ? and is_locked = 0
     * @param args         the parameter list
     * @return
     * @author liulongzhenhai 2013-9-9 下午5:14:48 <br>
     */
    <T extends Model> List<T> getBoList(Class<T> clazz, String sqlCondition, Object... args);

    /**
     * 通过sql获取类的结果集. <br>
     *
     * @param clazz        model
     * @param sqlCondition sql condition, the clause after "where" key, i.e. username = ? and is_locked = 0
     * @param args         the parameter list
     * @return
     * @author liulongzhenhai 2013-9-9 下午5:14:48 <br>
     */
    <T extends Model> List<Map<String, Object>> getMapList(Class<T> clazz, String sqlCondition, Object... args);

    /**
     * 通过指定的sql条件删除数据库 ,返回删除的总条数. <br>
     *
     * @param clazz
     * @param sqlCondition sql condition, the clause after "where" key, i.e. username = ? and is_locked = 0
     * @param args         the parameter list
     * @return
     * @author liulongzhenhai 2013-9-9 下午5:16:33 <br>
     */
    <T extends Model> int deleteBo(Class<T> clazz, String sqlCondition, Object... args);

    /**
     * 保存或者更新BO . <br>
     *
     * @param bo
     * @author liulongzhenhai 2013-9-9 下午5:21:41 <br>
     */
    <T extends Model> String saveOrUpdateBo(T bo);

    /**
     * 执行一个SQL语句. <br>
     *
     * @param sql
     * @author liulongzhenhai 2013-9-9 下午5:23:02 <br>
     */
    void sql(String sql);
}
